<?php include "userfunctions.php"; ?>
<html>
<head>
<title><?php title($title); ?> :Latest 10 Quotes</title>
<?php css($css); ?>
</head>
<body><center>
<? qheader(); ?>
<font face="arial" size="3">
<?php showlinks(); ?></center><br>
<div id="body">
<?php
$userip = $_SERVER["REMOTE_ADDR"];


$quote = $_GET['quote'];
$rating = $_GET['rating'];
$ip=$_SERVER['REMOTE_ADDR'];

if(($rating != "up") and ($rating != "down")){
     die("Hacking Attempt");
}

startsql();

if($rating == "up" or $rating == "down"){    // if rating is set to go up
    $ip_id = get_user_ip_id($ip);
    if(!$ip_id) { die();}
    $votecheck = check_vote($ip_id,$quote);
    if($votecheck != -99){ 
    // for now just die()
    echo "Sorry, but it seems as though you have already voted on this Quote.";
    } else {
        $change = 0;
        if($rating == "up") { $change = 1;}
	if($rating == "down") { $change = -1;}
        add_vote($ip_id,$quote,$change);
  //  echo '<meta http-equiv="refresh" content="0;url='.$_SERVER['REQUEST_URI'].'">';

    }
} 


?>
</div></body></html>
